import { sveltekit } from '@sveltejs/kit/vite';
import { babel } from '@rollup/plugin-babel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('vite').UserConfig} */
const config = {
	plugins: [
		// Configure SvelteKit with its preprocessor
		sveltekit({
			preprocess: vitePreprocess(),
		}),

		// Babel configuration
		babel({
			extensions: ['.js', '.mjs', '.html'],
			babelHelpers: 'runtime',
			exclude: ['node_modules/@babel/**'],
			presets: [
				[
					'@babel/preset-env',
					{
						targets: {
							node: 'current',
						},
					},
				],
			],
			plugins: [
				'@babel/plugin-transform-runtime',
				['@babel/plugin-proposal-decorators', { legacy: true }],
			],
		}),
	],
};

export default config;